var AIM, pictures, webservice, app = app ? app : null;

function start ()   
{
    app = Application.create ("PIMP");                                           
    app.using (featherweight.string.encoder );                                                
    app.using (featherweight.core);                                                
    app.using (featherweight.web);         
    app.using (featherweight.ui.display);   
    app.using (featherweight.ui.mouse);         
    app.onload = function () { AppConfig.load(); } 
    app.start();                   
}

function report (x)
{
    if (x) alert (x)
}

function startCallback() 
{
    Controller.StandbyPg.invoke();
    return true;
}

function completeCallback(response) 
{
    Controller.HomePage.invoke ();
}

function DeletePicture(id)
{
    if (!confirm ('Delete (0)?'.format(id))) return false;
    f=webservice.DeletePicture(id)
   // alert (f);
    Controller.HomePage.invoke ();
}
 

function window_w() { return document.all ? document.body.offsetWidth : window.innerWidth;}
function window_h() { return document.all ? document.body.offsetHeight : window.innerHeight;}

String.prototype.truncate=function(y) { try { return this.length>y?(this.substr(0,y/2)+'...'+this.substr(this.length-(y/2))):this } catch (ex) { return ''} }; 
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }; 
String.prototype.format = function ()
{
    var o=this;
    for (var i=0;i<arguments.length;i++)
        while (o.indexOf ('('+i+')')>=0)
            o=o.replace ('('+i+')', arguments[i]);
    return o;
}
function now() { return new Date().getTime() }